﻿#pragma once
#include <cstdint>

#define s2y(x) (x + 1900) /*年数转为年份值*/
#define y2s(x) (x - 1900) /*年份值转为年数*/
#define s2m(x) (x + 1)    /*月数转为月份值*/
#define m2s(x) (x - 1)    /*月份值转为月数*/
// 从1900年到2100年的农历月份数据代码 20位二进制代码表示一个年份的数据，
// 前四位0:表示闰月为29天，1:表示闰月为30天
// 中间12位：从左起表示1-12月每月的大小，1为30天，0为29天
// 最后四位：表示闰月的月份，0表示当年无闰月
// 前四位和最后四位应该结合使用，如果最后四位为0，则不考虑前四位
static constexpr unsigned int CHINESEYEARCODE[] = {
    19416,
    19168, 42352, 21717, 53856, 55632, 91476, 22176, 39632,
    21970, 19168, 42422, 42192, 53840, 119381, 46400, 54944,
    44450, 38320, 84343, 18800, 42160, 46261, 27216, 27968,
    109396, 11104, 38256, 21234, 18800, 25958, 54432, 59984,
    92821, 23248, 11104, 100067, 37600, 116951, 51536, 54432,
    120998, 46416, 22176, 107956, 9680, 37584, 53938, 43344,
    46423, 27808, 46416, 86869, 19872, 42416, 83315, 21168,
    43432, 59728, 27296, 44710, 43856, 19296, 43748, 42352,
    21088, 62051, 55632, 23383, 22176, 38608, 19925, 19152,
    42192, 54484, 53840, 54616, 46400, 46752, 103846, 38320,
    18864, 43380, 42160, 45690, 27216, 27968, 44870, 43872,
    38256, 19189, 18800, 25776, 29859, 59984, 27480, 23232,
    43872, 38613, 37600, 51552, 55636, 54432, 55888, 30034,
    22176, 43959, 9680, 37584, 51893, 43344, 46240, 47780,
    44368, 21977, 19360, 42416, 86390, 21168, 43312, 31060,
    27296, 44368, 23378, 19296, 42726, 42208, 53856, 60005,
    54576, 23200, 30371, 38608, 19195, 19152, 42192, 118966,
    53840, 54560, 56645, 46496, 22224, 21938, 18864, 42359,
    42160, 43600, 111189, 27936, 44448, 84835, 37744, 18936,
    18800, 25776, 92326, 59984, 27296, 108228, 43744, 37600,
    53987, 51552, 54615, 54432, 55888, 23893, 22176, 42704,
    21972, 21200, 43448, 43344, 46240, 46758, 44368, 21920,
    43940, 42416, 21168, 45683, 26928, 29495, 27296, 44368,
    84821, 19296, 42352, 21732, 53600, 59752, 54560, 55968,
    92838, 22224, 19168, 43476, 41680, 53584, 62034, 54560};
// 农历新年对应的公历日期
static constexpr uint8_t CHINESENEWYEAR[][3] = {
    {y2s(1900), m2s(1), 31},
    {y2s(1901), m2s(2), 19},
    {y2s(1902), m2s(2), 8},
    {y2s(1903), m2s(1), 29},
    {y2s(1904), m2s(2), 16},
    {y2s(1905), m2s(2), 4},
    {y2s(1906), m2s(1), 25},
    {y2s(1907), m2s(2), 13},
    {y2s(1908), m2s(2), 2},
    {y2s(1909), m2s(1), 22},
    {y2s(1910), m2s(2), 10},
    {y2s(1911), m2s(1), 30},
    {y2s(1912), m2s(2), 18},
    {y2s(1913), m2s(2), 6},
    {y2s(1914), m2s(1), 26},
    {y2s(1915), m2s(2), 14},
    {y2s(1916), m2s(2), 3},
    {y2s(1917), m2s(1), 23},
    {y2s(1918), m2s(2), 11},
    {y2s(1919), m2s(2), 1},
    {y2s(1920), m2s(2), 20},
    {y2s(1921), m2s(2), 8},
    {y2s(1922), m2s(1), 28},
    {y2s(1923), m2s(2), 16},
    {y2s(1924), m2s(2), 5},
    {y2s(1925), m2s(1), 24},
    {y2s(1926), m2s(2), 13},
    {y2s(1927), m2s(2), 2},
    {y2s(1928), m2s(1), 23},
    {y2s(1929), m2s(2), 10},
    {y2s(1930), m2s(1), 30},
    {y2s(1931), m2s(2), 17},
    {y2s(1932), m2s(2), 6},
    {y2s(1933), m2s(1), 26},
    {y2s(1934), m2s(2), 14},
    {y2s(1935), m2s(2), 4},
    {y2s(1936), m2s(1), 24},
    {y2s(1937), m2s(2), 11},
    {y2s(1938), m2s(1), 31},
    {y2s(1939), m2s(2), 19},
    {y2s(1940), m2s(2), 8},
    {y2s(1941), m2s(1), 27},
    {y2s(1942), m2s(2), 15},
    {y2s(1943), m2s(2), 5},
    {y2s(1944), m2s(1), 25},
    {y2s(1945), m2s(2), 13},
    {y2s(1946), m2s(2), 2},
    {y2s(1947), m2s(1), 22},
    {y2s(1948), m2s(2), 10},
    {y2s(1949), m2s(1), 29},
    {y2s(1950), m2s(2), 17},
    {y2s(1951), m2s(2), 6},
    {y2s(1952), m2s(1), 27},
    {y2s(1953), m2s(2), 14},
    {y2s(1954), m2s(2), 3},
    {y2s(1955), m2s(1), 24},
    {y2s(1956), m2s(2), 12},
    {y2s(1957), m2s(1), 31},
    {y2s(1958), m2s(2), 18},
    {y2s(1959), m2s(2), 8},
    {y2s(1960), m2s(1), 28},
    {y2s(1961), m2s(2), 15},
    {y2s(1962), m2s(2), 5},
    {y2s(1963), m2s(1), 25},
    {y2s(1964), m2s(2), 13},
    {y2s(1965), m2s(2), 2},
    {y2s(1966), m2s(1), 21},
    {y2s(1967), m2s(2), 9},
    {y2s(1968), m2s(1), 30},
    {y2s(1969), m2s(2), 17},
    {y2s(1970), m2s(2), 6},
    {y2s(1971), m2s(1), 27},
    {y2s(1972), m2s(2), 15},
    {y2s(1973), m2s(2), 3},
    {y2s(1974), m2s(1), 23},
    {y2s(1975), m2s(2), 11},
    {y2s(1976), m2s(1), 31},
    {y2s(1977), m2s(2), 18},
    {y2s(1978), m2s(2), 7},
    {y2s(1979), m2s(1), 28},
    {y2s(1980), m2s(2), 16},
    {y2s(1981), m2s(2), 5},
    {y2s(1982), m2s(1), 25},
    {y2s(1983), m2s(2), 13},
    {y2s(1984), m2s(2), 2},
    {y2s(1985), m2s(2), 20},
    {y2s(1986), m2s(2), 9},
    {y2s(1987), m2s(1), 29},
    {y2s(1988), m2s(2), 17},
    {y2s(1989), m2s(2), 6},
    {y2s(1990), m2s(1), 27},
    {y2s(1991), m2s(2), 15},
    {y2s(1992), m2s(2), 4},
    {y2s(1993), m2s(1), 23},
    {y2s(1994), m2s(2), 10},
    {y2s(1995), m2s(1), 31},
    {y2s(1996), m2s(2), 19},
    {y2s(1997), m2s(2), 7},
    {y2s(1998), m2s(1), 28},
    {y2s(1999), m2s(2), 16},
    {y2s(2000), m2s(2), 5},
    {y2s(2001), m2s(1), 24},
    {y2s(2002), m2s(2), 12},
    {y2s(2003), m2s(2), 1},
    {y2s(2004), m2s(1), 22},
    {y2s(2005), m2s(2), 9},
    {y2s(2006), m2s(1), 29},
    {y2s(2007), m2s(2), 18},
    {y2s(2008), m2s(2), 7},
    {y2s(2009), m2s(1), 26},
    {y2s(2010), m2s(2), 14},
    {y2s(2011), m2s(2), 3},
    {y2s(2012), m2s(1), 23},
    {y2s(2013), m2s(2), 10},
    {y2s(2014), m2s(1), 31},
    {y2s(2015), m2s(2), 19},
    {y2s(2016), m2s(2), 8},
    {y2s(2017), m2s(1), 28},
    {y2s(2018), m2s(2), 16},
    {y2s(2019), m2s(2), 5},
    {y2s(2020), m2s(1), 25},
    {y2s(2021), m2s(2), 12},
    {y2s(2022), m2s(2), 1},
    {y2s(2023), m2s(1), 22},
    {y2s(2024), m2s(2), 10},
    {y2s(2025), m2s(1), 29},
    {y2s(2026), m2s(2), 17},
    {y2s(2027), m2s(2), 6},
    {y2s(2028), m2s(1), 26},
    {y2s(2029), m2s(2), 13},
    {y2s(2030), m2s(2), 3},
    {y2s(2031), m2s(1), 23},
    {y2s(2032), m2s(2), 11},
    {y2s(2033), m2s(1), 31},
    {y2s(2034), m2s(2), 19},
    {y2s(2035), m2s(2), 8},
    {y2s(2036), m2s(1), 28},
    {y2s(2037), m2s(2), 15},
    {y2s(2038), m2s(2), 4},
    {y2s(2039), m2s(1), 24},
    {y2s(2040), m2s(2), 12},
    {y2s(2041), m2s(2), 1},
    {y2s(2042), m2s(1), 22},
    {y2s(2043), m2s(2), 10},
    {y2s(2044), m2s(1), 30},
    {y2s(2045), m2s(2), 17},
    {y2s(2046), m2s(2), 6},
    {y2s(2047), m2s(1), 26},
    {y2s(2048), m2s(2), 14},
    {y2s(2049), m2s(2), 2},
    {y2s(2050), m2s(1), 23},
    {y2s(2051), m2s(2), 11},
    {y2s(2052), m2s(2), 1},
    {y2s(2053), m2s(2), 19},
    {y2s(2054), m2s(2), 8},
    {y2s(2055), m2s(1), 28},
    {y2s(2056), m2s(2), 15},
    {y2s(2057), m2s(2), 4},
    {y2s(2058), m2s(1), 24},
    {y2s(2059), m2s(2), 12},
    {y2s(2060), m2s(2), 2},
    {y2s(2061), m2s(1), 21},
    {y2s(2062), m2s(2), 9},
    {y2s(2063), m2s(1), 29},
    {y2s(2064), m2s(2), 17},
    {y2s(2065), m2s(2), 5},
    {y2s(2066), m2s(1), 26},
    {y2s(2067), m2s(2), 14},
    {y2s(2068), m2s(2), 3},
    {y2s(2069), m2s(1), 23},
    {y2s(2070), m2s(2), 11},
    {y2s(2071), m2s(1), 31},
    {y2s(2072), m2s(2), 19},
    {y2s(2073), m2s(2), 7},
    {y2s(2074), m2s(1), 27},
    {y2s(2075), m2s(2), 15},
    {y2s(2076), m2s(2), 5},
    {y2s(2077), m2s(1), 24},
    {y2s(2078), m2s(2), 12},
    {y2s(2079), m2s(2), 2},
    {y2s(2080), m2s(1), 22},
    {y2s(2081), m2s(2), 9},
    {y2s(2082), m2s(1), 29},
    {y2s(2083), m2s(2), 17},
    {y2s(2084), m2s(2), 6},
    {y2s(2085), m2s(1), 26},
    {y2s(2086), m2s(2), 14},
    {y2s(2087), m2s(2), 3},
    {y2s(2088), m2s(1), 24},
    {y2s(2089), m2s(2), 10},
    {y2s(2090), m2s(1), 30},
    {y2s(2091), m2s(2), 18},
    {y2s(2092), m2s(2), 7},
    {y2s(2093), m2s(1), 27},
    {y2s(2094), m2s(2), 15},
    {y2s(2095), m2s(2), 5},
    {y2s(2096), m2s(1), 25},
    {y2s(2097), m2s(2), 12},
    {y2s(2098), m2s(2), 1},
    {y2s(2099), m2s(1), 21},
    {y2s(2100), m2s(2), 9}};

static constexpr const char *ZHNUMS[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"};
static constexpr const char *shengxiao[] = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
// 天干
static constexpr const char *TIANGAN[] = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
// 地支
static constexpr const char *DIZHI[] = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
static constexpr const auto DAY_TIMES = 86400; // 一天的秒数